<template>
	<!-- 登录 -->
	<view class="login">
		<view class="login_box">
			<!-- <view style="width: 100%;height: 20rpx;"></view> -->
			<view class="login_box_logo">
				<image src="../../../static/my/my-1.png" mode=""></image>
			</view>
			<view style="margin-top: 18rpx;width: 100%;text-align: center;">
				<image style="width: 180rpx;height: 62rpx;" src="../../../static/my/my-2.png" mode=""></image>
			</view>
			<view style="width: 100%;height: 20rpx;"></view>
			<view style="width: 100%;">
				<view class="login_form_item">
				    <input type="text" v-model.trim="ruleForm.account" placeholder="输入登录账号" />
				</view>
				<view class="login_form_item">
				    <input  type="text" v-model.trim="ruleForm.pwd" placeholder="输入登录密码" />
				</view>
			</view>
			<view style="width: 100%;height: 82rpx;"></view>
			<view style="width: 100%;" class="login_box_btn">
				<button :disabled="clicklogin ?false:true"  @click="updateUserInfo">
					<!-- <image style="width: 54rpx;height: 44rpx;vertical-align: middle;" src="https://dszhzy.oss-cn-beijing.aliyuncs.com/7482e845d2754ba784c8f35e5d98b05d.png" mode=""></image> -->
					<text style="color: #FFFFFF;vertical-align: middle;font-size: 32rpx;font-weight: 500;">登录</text> 
				</button>
			</view>
		
		</view>
		<!-- 提示内容 -->
		<u-toast ref="uToast" />
		<!-- 提示内容结束 -->
	</view>
	<!-- 登录结束 -->
</template>

<script>
	export default {
		data() {
			return {
				clicklogin: true,
				ruleForm:{
					account:"",
					pwd:"",
				},
			}
		},
		onLoad() {
			uni.hideHomeButton();
		},
		methods: {
			//向后台更新信息
			updateUserInfo() {
				if(this.ruleForm.account ==''){
					this.$refs.uToast.show({
						title: '输入登录账号',
						type: 'warning',
						icon: false,
						duration:'1500'
					})
					return;
				}else if(this.ruleForm.pwd ==''){
					this.$refs.uToast.show({
						title: '输入登录密码',
						type: 'warning',
						icon: false,
						duration:'1500'
					})
					return;		
				}else{
					if(this.clicklogin){
						let opts = {
							way: true, //true JSON请求；false 表单请求
							method: 'post',
							url: 'pickup-point/pwd/login'
						};
						let data = {
							account:this.ruleForm.account,
							pwd:this.ruleForm.pwd
						};
						this.http.httpTokenRequest(opts, data).then(res => {
							//打印请求返回的数据
							let data = res.data;
							if (res.code == 200) {
								uni.setStorageSync('token', data.token);
								this.goIndex();
								
							} else {
								this.$refs.uToast.show({
									title: res.message,
									icon: false,
									type: 'error',
									duration:'1500'
								})
							}
						});
					}else{
						this.$refs.uToast.show({
							title: '请勿连续点击',
							type: 'warning',
							icon: false,
							duration:'1500'
						})
					}
				}
				
				
			},
			// 去首页
			goIndex(){
				uni.switchTab({
					url:'/pages/index/index'
				})
				
			},
		}
	}
</script>

<style scoped >
	.login {width: 100%;height: 100vh;padding: 0;margin: 0;background: #FFFFFF;position: relative;}
	.login_box{width: 86%;margin: 0 auto;padding-top: 14%;}
	.login_box_logo{width: 100%;height: auto;text-align: center;}
	.login_box_logo image{width: 200rpx;height: 200rpx;}
	.login_box_btn button{background-color: #0E5FED ;border-color: #0E5FED ;border: none;height: 90rpx;line-height: 90rpx;border-radius: 45rpx !important;}
	.login_box_btn button[disabled] {
	    background-color: #0E5FED;
	    color: rgba(0,0,0,.5);
	}
	.login_form_item {
	    width: 100%;
	    border-bottom: 2rpx solid #e3e3e3;
		margin-top: 20rpx;
	}
	.login_form_item input {
	    width: 100%;
	    line-height: 40rpx;
	    color: 666666;
	    font-size: 28rpx;
	    padding: 30rpx 0rpx;
	}
</style>
